<!DOCTYPE html>



  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">



  
  
    
    
  <script src="/lib/pace/pace.min.js?v=1.0.2"></script>
  <link href="/lib/pace/pace-theme-minimal.min.css?v=1.0.2" rel="stylesheet">







<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.2" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Git,Github," />





  <link rel="alternate" href="/atom.xml" title="微凉的博客" type="application/atom+xml" />




  <link rel="shortcut icon" type="image/x-icon" href="/images/favicon.ico?v=5.1.2" />






<meta name="description" content="远程登录 telnet 一种不加密的通信协议 ssh 一种协议，用来实现两台计算机之间的通信（具体就是实现远程登录） 使用密码登录 首先客户端向服务器发送一个请求 服务器接收到请求之后向客户度发送自己的公钥 客户端接收到公钥之后存储到指定目录（C:\Users\www.ssh） 客户端输入密码然后用公钥加密，再次发送请求 服务器接收到密文之后，使用自己的私钥揭秘然后验证通过，从而允许客户端登录">
<meta name="keywords" content="Git,Github">
<meta property="og:type" content="article">
<meta property="og:title" content="Github以及远程仓库">
<meta property="og:url" content="http://yoursite.com/2017/09/14/Github以及远程仓库 201709142104/index.html">
<meta property="og:site_name" content="微凉的博客">
<meta property="og:description" content="远程登录 telnet 一种不加密的通信协议 ssh 一种协议，用来实现两台计算机之间的通信（具体就是实现远程登录） 使用密码登录 首先客户端向服务器发送一个请求 服务器接收到请求之后向客户度发送自己的公钥 客户端接收到公钥之后存储到指定目录（C:\Users\www.ssh） 客户端输入密码然后用公钥加密，再次发送请求 服务器接收到密文之后，使用自己的私钥揭秘然后验证通过，从而允许客户端登录">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="http://img.blog.csdn.net/20170914214634742?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast">
<meta property="og:image" content="http://img.blog.csdn.net/20170914215131020?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast">
<meta property="og:image" content="http://img.blog.csdn.net/20170914220155211?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast">
<meta property="og:image" content="http://img.blog.csdn.net/20170914220450802?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast">
<meta property="og:image" content="http://img.blog.csdn.net/20170914220933825?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast">
<meta property="og:image" content="http://img.blog.csdn.net/20170914210710222?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast">
<meta property="og:image" content="http://img.blog.csdn.net/20170914210734547?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast">
<meta property="og:image" content="http://img.blog.csdn.net/20170914211605786?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast">
<meta property="og:image" content="http://img.blog.csdn.net/20170914212617870?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast">
<meta property="og:image" content="http://img.blog.csdn.net/20170914214002141?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast">
<meta property="og:image" content="http://img.blog.csdn.net/20170914213045205?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast">
<meta property="og:image" content="http://img.blog.csdn.net/20170915153123323?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast">
<meta property="og:image" content="http://img.blog.csdn.net/20170915154431409?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast">
<meta property="og:image" content="http://img.blog.csdn.net/20170915153956219?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast">
<meta property="og:image" content="http://img.blog.csdn.net/20170915155218417?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast">
<meta property="og:image" content="http://img.blog.csdn.net/20170915155913362?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast">
<meta property="og:image" content="http://img.blog.csdn.net/20170915161629524?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast">
<meta property="og:image" content="http://img.blog.csdn.net/20170915164002524?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast">
<meta property="og:image" content="http://img.blog.csdn.net/20170915164159538?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast">
<meta property="og:image" content="http://img.blog.csdn.net/20170915164654651?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast">
<meta property="og:image" content="http://img.blog.csdn.net/20170915164811749?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast">
<meta property="og:image" content="http://img.blog.csdn.net/20170915164940207?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast">
<meta property="og:image" content="http://img.blog.csdn.net/20170915165135812?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast">
<meta property="og:updated_time" content="2017-09-15T09:39:20.993Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Github以及远程仓库">
<meta name="twitter:description" content="远程登录 telnet 一种不加密的通信协议 ssh 一种协议，用来实现两台计算机之间的通信（具体就是实现远程登录） 使用密码登录 首先客户端向服务器发送一个请求 服务器接收到请求之后向客户度发送自己的公钥 客户端接收到公钥之后存储到指定目录（C:\Users\www.ssh） 客户端输入密码然后用公钥加密，再次发送请求 服务器接收到密文之后，使用自己的私钥揭秘然后验证通过，从而允许客户端登录">
<meta name="twitter:image" content="http://img.blog.csdn.net/20170914214634742?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/2017/09/14/Github以及远程仓库 201709142104/"/>







  <title>Github以及远程仓库 | 微凉的博客</title>
  














</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">微凉的博客</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-commonweal">
          <a href="/404/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-heartbeat"></i> <br />
            
            公益404
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2017/09/14/Github以及远程仓库 201709142104/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="微凉">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="微凉的博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Github以及远程仓库</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-09-14T22:12:50+08:00">
                2017-09-14
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          
            <span class="post-meta-divider">|</span>
            <span class="page-pv"><i class="fa fa-file-o"></i>
            <span class="busuanzi-value" id="busuanzi_value_page_pv" ></span>
            </span>
          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="远程登录"><a href="#远程登录" class="headerlink" title="远程登录"></a>远程登录</h2><ul>
<li>telnet 一种不加密的通信协议</li>
<li>ssh 一种协议，用来实现两台计算机之间的通信（具体就是实现远程登录）<ul>
<li>使用密码登录<ul>
<li>首先客户端向服务器发送一个请求</li>
<li>服务器接收到请求之后向客户度发送自己的公钥</li>
<li>客户端接收到公钥之后存储到指定目录（C:\Users\www.ssh）</li>
<li>客户端输入密码然后用公钥加密，再次发送请求</li>
<li>服务器接收到密文之后，使用自己的私钥揭秘然后验证通过，从而允许客户端登录</li>
</ul>
</li>
<li>使用公钥和私钥登录<ul>
<li>客户端先生成自己的公钥和私钥（ssh-keygen -t rsa）</li>
<li>把客户端的公钥传递给服务器，服务器使用该公钥给客户端授权</li>
<li>客户端直接就可以免密登录了<h4 id="创建公钥和私钥"><a href="#创建公钥和私钥" class="headerlink" title="创建公钥和私钥"></a>创建公钥和私钥</h4></li>
</ul>
</li>
</ul>
</li>
</ul>
<ol>
<li>在任意位置执行命令（一直回车 看到下图则证明成功）</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">ssh-keygen</div></pre></td></tr></table></figure>
<p><img src="http://img.blog.csdn.net/20170914214634742?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="生成密钥"></p>
<blockquote>
<p>密钥生成的位置在C:\Users\94930.ssh 目录下<br>登陆Github创建一个项目<br><img src="http://img.blog.csdn.net/20170914215131020?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="创建项目"></p>
<p>会自动生成一个远程仓库的地址</p>
</blockquote>
<p><img src="http://img.blog.csdn.net/20170914220155211?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="仓库地址"></p>
<blockquote>
<p>添加自己的公钥<br><img src="http://img.blog.csdn.net/20170914220450802?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="添加公钥"></p>
<p>推送代码<br><img src="http://img.blog.csdn.net/20170914220933825?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="推送代码"></p>
</blockquote>
<p>这样就可以把本地的仓库推送到线上了</p>
<hr>
<blockquote>
<p>对称加密<br><img src="http://img.blog.csdn.net/20170914210710222?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="加密方式"><br>非对称加密<br><img src="http://img.blog.csdn.net/20170914210734547?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="加密方式"></p>
</blockquote>
<h2 id="远程（共享）仓库"><a href="#远程（共享）仓库" class="headerlink" title="远程（共享）仓库"></a>远程（共享）仓库</h2><blockquote>
<p>借助一个远程仓库，大家可以共享代码、历史版本等数据，实现团队成员之间代码同步。</p>
</blockquote>
<h2 id="远程仓库操作流程"><a href="#远程仓库操作流程" class="headerlink" title="远程仓库操作流程"></a>远程仓库操作流程</h2><h3 id="创建远程仓库"><a href="#创建远程仓库" class="headerlink" title="创建远程仓库"></a>创建远程仓库</h3><ol>
<li>创建以.git结尾的目录</li>
<li>进入该目录</li>
<li>初始化共享仓库</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">git init --bare</div></pre></td></tr></table></figure>
<p><img src="http://img.blog.csdn.net/20170914211605786?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="创建仓库"></p>
<blockquote>
<p>这样我们就建好了一个共享的仓库，但这时这个仓库是一个空的仓库，并且不允在这个仓库中进行任何修改。</p>
</blockquote>
<h3 id="向共享仓库推送内容"><a href="#向共享仓库推送内容" class="headerlink" title="向共享仓库推送内容"></a>向共享仓库推送内容</h3><blockquote>
<p>将自已开发的项目同步到这个目录中，其它开发者就可以共享你开发的项目了。</p>
</blockquote>
<ul>
<li>上传代码<ul>
<li>进入自己的项目跟目录</li>
<li><code>git push 远程仓库的地址 本地分支名称:远程分支名称</code></li>
<li><code>git push 远程仓库的地址 本地分支名称</code><br><img src="http://img.blog.csdn.net/20170914212617870?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="上传代码"><blockquote>
<p>如果要上传的文件的本地分支和远程分支一样的话，则远程分支可以省略不写</p>
</blockquote>
</li>
</ul>
</li>
<li>下载代码<ul>
<li><code>git pull 远程仓库的地址 远程分支名称:本地分支名称</code></li>
<li><code>git pull 远程仓库的地址 远程分支名称</code><br><img src="http://img.blog.csdn.net/20170914214002141?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="下载"><blockquote>
<p>如果要下载的文件的本地分支和远程分支一样的话，则本地分支可以省略不写<br><strong>如果是第一次下载代码一般使用如下命令</strong></p>
</blockquote>
</li>
</ul>
</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">git clone 远程仓库的地址 [项目名称]</div></pre></td></tr></table></figure>
<blockquote>
<p>后面的项目名称可以不写 如果不写则名称和上传的项目名称是一致的<br>克隆下来的项目自动建立了跟踪分支</p>
</blockquote>
<p><img src="http://img.blog.csdn.net/20170914213045205?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="克隆代码"></p>
<ul>
<li>查看仓库的别名（后面是空的表示没有别名）</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">git remote</div></pre></td></tr></table></figure>
<p><img src="http://img.blog.csdn.net/20170915153123323?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="仓库别名"></p>
<ul>
<li>查看别名的详细信息</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">git remote -v</div></pre></td></tr></table></figure>
<p><img src="http://img.blog.csdn.net/20170915154431409?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="别名详细信息"></p>
<ul>
<li>添加别名（别名一般为origin）</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">git remote add 别名名称 远程仓库地址</div></pre></td></tr></table></figure>
<p><img src="http://img.blog.csdn.net/20170915153956219?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="新建仓库"></p>
<ul>
<li>建立跟踪分支的推送</li>
</ul>
<blockquote>
<p>-u 的意思就是建立跟踪分支 只需要建立一次就会自动记住要推送的地址和分支，以后如果需要再推送内容就可以直接执行git push</p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">git push -u origin master</div></pre></td></tr></table></figure>
<p><img src="http://img.blog.csdn.net/20170915155218417?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="这里写图片描述"></p>
<ul>
<li>查看远程分支</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">git branch -r</div></pre></td></tr></table></figure>
<p><img src="http://img.blog.csdn.net/20170915155913362?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="远程分支"></p>
<ul>
<li>查看本地和远程分支</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">git branch -a</div></pre></td></tr></table></figure>
<p><img src="http://img.blog.csdn.net/20170915161629524?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="这里写图片描述"></p>
<ul>
<li>远程仓库中有了新的内容而本地仓库没有更新而出现的问题（所以推送前最好先从远程仓库下载最新的文件）<br><img src="http://img.blog.csdn.net/20170915164002524?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="错误详情"></li>
<li>解决的办法</li>
<li>先下载<br><img src="http://img.blog.csdn.net/20170915164159538?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="解决"></li>
<li>打开文件<br><img src="http://img.blog.csdn.net/20170915164654651?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="这里写图片描述"></li>
<li>选择你想留下的文件<br><img src="http://img.blog.csdn.net/20170915164811749?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="这里写图片描述"><br><img src="http://img.blog.csdn.net/20170915164940207?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="这里写图片描述"></li>
<li>然后在重新推送即可<br><img src="http://img.blog.csdn.net/20170915165135812?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTDIyMDUzMDY3NDQ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="这里写图片描述"></li>
<li>删除远程分支</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">git push origin --delete 分支名称</div><div class="line">git push origin :分支名称</div></pre></td></tr></table></figure>
<ul>
<li>保存现场</li>
</ul>
<blockquote>
<p>可以暂时的保存还未做完的任务（保存工作目录和暂存区）然后就可以先去做别的任务</p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">git stash</div></pre></td></tr></table></figure>
<blockquote>
<p>恢复</p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">git stash pop</div></pre></td></tr></table></figure>
<ul>
<li>忽略文件的方式<br>在项目根目录下创建一个.gitignore文件，可以将不希望提交的文件名称写在这个文件中，作用是排除一些文件或者目录，使其不被git管理</li>
</ul>
<blockquote>
<p><a href="https://github.com/github/gitignore" target="_blank" rel="external">gitignore文档</a></p>
</blockquote>
<ul>
<li>比较差异<br>当内容被修改，我们无法确定修改哪些内容时，可以通过git diff来进行差异比较</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">git difftoll   (比较的是工作区与暂存区的差异)</div><div class="line">git difftool (加上要比较的commitID)   （比较工作区与某次提交之间的差异）</div><div class="line">git difftool (第一个commitID，第二个commitID)   （比较两次提交的内容间的差异）</div><div class="line">git difftool 分支名称 比较与摸个分支的差异</div></pre></td></tr></table></figure>
      
    </div>
    
    
    



    



    
      <div>
        <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
  <div>坚持原创技术分享，您的支持将鼓励我继续创作！</div>
  <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
    <span>Donate</span>
  </button>
  <div id="QR" style="display: none;">

    
      <div id="wechat" style="display: inline-block">
        <img id="wechat_qr" src="http://ovi21695e.bkt.clouddn.com/wechat.png" alt="微凉 WeChat Pay"/>
        <p>WeChat Pay</p>
      </div>
    

    
      <div id="alipay" style="display: inline-block">
        <img id="alipay_qr" src="http://ovi21695e.bkt.clouddn.com/zhifubao.png" alt="微凉 Alipay"/>
        <p>Alipay</p>
      </div>
    

    

  </div>
</div>

      </div>
    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Git/" rel="tag"><i class="fa fa-tag"></i> Git</a>
          
            <a href="/tags/Github/" rel="tag"><i class="fa fa-tag"></i> Github</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/09/14/Git基础-分支的基本操作 201709142054/" rel="next" title="Git基础-分支">
                <i class="fa fa-chevron-left"></i> Git基础-分支
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
        <!-- JiaThis Button BEGIN -->
<div class="jiathis_style">
  <a class="jiathis_button_tsina"></a>
  <a class="jiathis_button_tqq"></a>
  <a class="jiathis_button_weixin"></a>
  <a class="jiathis_button_cqq"></a>
  <a class="jiathis_button_douban"></a>
  <a class="jiathis_button_renren"></a>
  <a class="jiathis_button_qzone"></a>
  <a class="jiathis_button_kaixin001"></a>
  <a class="jiathis_button_copy"></a>
  <a href="http://www.jiathis.com/share" class="jiathis jiathis_txt jiathis_separator jtico jtico_jiathis" target="_blank"></a>
  <a class="jiathis_counter_style"></a>
</div>
<script type="text/javascript" >
  var jiathis_config={
    hideMore:false
  }
</script>
<script type="text/javascript" src="http://v3.jiathis.com/code/jia.js" charset="utf-8"></script>
<!-- JiaThis Button END -->

      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div id="lv-container" data-id="city" data-uid="MTAyMC8zMDQ5NC83MDQ4"></div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/avatar.png"
               alt="微凉" />
          <p class="site-author-name" itemprop="name">微凉</p>
           
              <p class="site-description motion-element" itemprop="description"></p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/archives/">
                <span class="site-state-item-count">5</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">2</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        
          <div class="feed-link motion-element">
            <a href="/atom.xml" rel="alternate">
              <i class="fa fa-rss"></i>
              RSS
            </a>
          </div>
        

        <div class="links-of-author motion-element">
          
        </div>

        
        

        
        
          <div class="links-of-blogroll motion-element links-of-blogroll-inline">
            <div class="links-of-blogroll-title">
              <i class="fa  fa-fw fa-globe"></i>
              推荐阅读
            </div>
            <ul class="links-of-blogroll-list">
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.uisdc.com/" title="优设" target="_blank">优设</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://mlizheng.github.io/TIME/" title="李征" target="_blank">李征</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.alloyteam.com/nav/" title="Web前端导航" target="_blank">Web前端导航</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.36zhen.com/t?id=3448" title="前端书籍资料" target="_blank">前端书籍资料</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://ife.baidu.com/" title="百度前端技术学院" target="_blank">百度前端技术学院</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://wf.uisdc.com/cn/" title="google前端开发基础" target="_blank">google前端开发基础</a>
                </li>
              
            </ul>
          </div>
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#远程登录"><span class="nav-number">1.</span> <span class="nav-text">远程登录</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#创建公钥和私钥"><span class="nav-number">1.0.1.</span> <span class="nav-text">创建公钥和私钥</span></a></li></ol></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#远程（共享）仓库"><span class="nav-number">2.</span> <span class="nav-text">远程（共享）仓库</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#远程仓库操作流程"><span class="nav-number">3.</span> <span class="nav-text">远程仓库操作流程</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#创建远程仓库"><span class="nav-number">3.1.</span> <span class="nav-text">创建远程仓库</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#向共享仓库推送内容"><span class="nav-number">3.2.</span> <span class="nav-text">向共享仓库推送内容</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy;  1996 - 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-hand-o-right" aria-hidden="true"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">微凉</span>
</div>


<!-- <div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Pisces
  </a>
</div>

-->

        
<div class="busuanzi-count">
  <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv">
      <i class="fa fa-user"></i>
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
      
    </span>
  

  
    <span class="site-pv">
      <i class="fa fa-eye"></i>
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
      
    </span>
  
</div>


        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  


  











  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>

  
  <script type="text/javascript" src="/lib/canvas-nest/canvas-nest.min.js"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.2"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.2"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.2"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.2"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.2"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.2"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.2"></script>



  


  




	





  





  
    <script type="text/javascript">
      (function(d, s) {
        var j, e = d.getElementsByTagName(s)[0];
        if (typeof LivereTower === 'function') { return; }
        j = d.createElement(s);
        j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
        j.async = true;
        e.parentNode.insertBefore(j, e);
      })(document, 'script');
    </script>
  






  





  

  

  

  

  

  

</body>
</html>
